package com.sca4cloud.sca.microservice;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.actuate.autoconfigure.security.servlet.ManagementWebSecurityAutoConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.security.oauth2.OAuth2AutoConfiguration;
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
import org.springframework.boot.autoconfigure.security.servlet.SecurityFilterAutoConfiguration;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.ConfigurableApplicationContext;

import com.sca4cloud.sca.common.feign.annotation.EnableScaFeignClients;
import com.sca4cloud.sca.common.ide.util.NacosParm;
import com.sca4cloud.sca.common.security.annotation.EnableScaResourceServer;
import com.sca4cloud.sca.common.swagger.annotation.EnableScaSwagger2;

@EnableScaSwagger2
// 开启多数据源,开启时注意pom文件增加引用。@EnableAutoConfiguration 注解增加 排除类：DruidDataSourceAutoConfigure.class,
//@EnableDynamicDataSource
//扫描：bc=业务组件包。dempapp=交易包
//@SpringBootApplication(scanBasePackages={"com.sca4cloud.sca.microservice","bc","demoapp"})
@SpringBootApplication
@EnableDiscoveryClient
// 开启feign接口支持
@EnableScaFeignClients
// 开启Oauth2 资源中心，需要权限访问
@EnableScaResourceServer
// exclude 自动配置类，禁用spring secutity 验证，如果需要要验证，将exclude 的类删除即可
//@EnableAutoConfiguration(exclude = {SecurityAutoConfiguration.class,OAuth2AutoConfiguration.class,
//    SecurityFilterAutoConfiguration.class, ManagementWebSecurityAutoConfiguration.class })
//DruidDataSourceAutoConfigure.class,
public class MicroMainApplication {

	public static void main(String[] args) {
		ConfigurableApplicationContext context = SpringApplication.run(MicroMainApplication.class, args);
		NacosParm.serverAddr = context.getEnvironment().getProperty("spring.cloud.nacos.discovery.server-addr")
				.split(":")[0];
	}

}
